/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package com.cratos.xxgramoss.user;

import com.cratos.xxgram.platf.base.BaseService;
import com.cratos.xxgram.platf.sysnotice.SystemNotice;
import com.cratos.xxgram.platf.sysnotice.SystemNoticeService;
import com.cratos.xxgramoss.base.MemberInfo;
import javax.annotation.Resource;
import org.redkale.net.http.RestService;
import org.redkale.source.*;
import org.redkale.util.*;
import static com.cratos.xxgramoss.base.Services.*;
import org.redkale.net.http.*;
import org.redkale.service.RetResult;

/**
 *
 * @author alter
 */
@RestService(comment = "系统公告", moduleid = MODULE_ANNOUNCE)
public class SystemNoticeOssService extends BaseService {

    @Resource(name = "platf")
    protected DataSource platfSource;

    @Resource
    protected SystemNoticeService systemNoticeService;
    
    @RestMapping(auth = true, actionid = ACTION_QUERY, comment = "查询公告信息")
    public RetResult<Sheet<SystemNotice>> queryNoticeList(SystemNoticeBean bean, Flipper flipper) {
        Sheet<SystemNotice> sheet = platfSource.querySheet(SystemNotice.class, flipper, bean);
        return new RetResult<>(sheet);
    }
    
    @RestMapping(auth = true, actionid = ACTION_CREATE, comment = "新增公告")
    public RetResult createNotice(MemberInfo member, @RestParam(name = "bean") SystemNotice bean) {
        return systemNoticeService.createSystemNotice(member.getMemberid(),bean);
    }
    
    @RestMapping(auth = true, actionid = ACTION_UPDATE, comment = "关闭")
    public RetResult updateStatus(String sysnoticeid) {
        return systemNoticeService.updateNoticeStatus(sysnoticeid, SystemNotice.CLOSE_STATUS);
    }

    @RestMapping(auth = true, actionid = ACTION_QUERY, comment = "查询公告详情")
    public RetResult<SystemNotice> findNoticeDetail(String sysnoticeid) {
        SystemNotice notice = platfSource.find(SystemNotice.class, sysnoticeid);
        return new RetResult<>(notice);
    }
    
}
